import hashlib
from django.db import models
from django.conf import settings


class BaseModel(models.Model):
    is_show = models.BooleanField(verbose_name='展示', default=True)
    is_delete = models.BooleanField(verbose_name='删除', default=False)
    create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    # update_time = models.DateTimeField(verbose_name='更新时间', auto_now=True)
    # order = models.SmallIntegerField(verbose_name='排序', default=1)

    class Meta:
        # 抽象表,不在生成新的表
        abstract = True


def md5(string):
    """ MD5加密 """
    hash_object = hashlib.md5(settings.SECRET_KEY.encode('utf-8'))
    hash_object.update(string.encode('utf-8'))
    return hash_object.hexdigest()
